package smedi.ismedi.mobile.bff.controller.inmail;

import com.smedi.ismedi.inmail.api.dto.request.appVersion.*;
import com.smedi.ismedi.inmail.api.dto.response.AppVersionResponse;
import com.smedi.ismedi.inmail.api.dto.response.CheckVersionResponse;
import com.smedi.ismedi.inmail.api.feign.RemoteAppVersionFeignApi;
import com.smedi.ismedi.web.starter.common.PaginationData;
import com.smedi.ismedi.web.starter.common.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * @className: AppVersionController
 * @Description: TODO
 * @version: v1.0.0
 * @author: wzx
 * @date: 2023/8/30 14:57
 */

@Slf4j
@Api(value = "App版本管理" , tags = {"App版本管理"})
@RequestMapping(value = "/mobilebff/v1/app/version" )
@RestController
@RequiredArgsConstructor
public class AppVersionController {

    private final RemoteAppVersionFeignApi remoteAppVersionFeignApi;

    /**
     * 新增 发布
     *
     * @param appVersionCreateRequest 发布 新增 请求
     * @return ResponseData < Long>
     */
    @Operation(summary = "新增 APP版本", description = "新增 APP版本")
    @PostMapping(value = "/create")
    ResponseData<Long> create(@Valid @RequestBody AppVersionCreateRequest appVersionCreateRequest){
        return remoteAppVersionFeignApi.create(appVersionCreateRequest);
    }

    /**
     * 更新 发布
     *
     * @param appVersionUpdateRequest 发布 更新 请求
     * @return ResponseData < Long>
     */
    @Operation(summary = "更新 APP版本", description = "更新 APP版本")
    @PostMapping(value = "/update")
    ResponseData<Long> update(@Valid @RequestBody AppVersionUpdateRequest appVersionUpdateRequest){
        return remoteAppVersionFeignApi.update(appVersionUpdateRequest);
    }

    /**
     * 删除 发布
     *
     * @param appVersionRemoveRequest 发布 删除 请求
     * @return ResponseData < Void>
     */
    @Operation(summary = "删除 APP版本", description = "删除 APP版本")
    @PostMapping(value = "/remove")
    ResponseData<Boolean> remove(@Valid @RequestBody AppVersionRemoveRequest appVersionRemoveRequest){
        return remoteAppVersionFeignApi.remove(appVersionRemoveRequest);
    }

    /**
     * 启用 发布
     *
     * @param appVersionEnableRequest 发布 启用 请求
     * @return ResponseData < Void>
     */
    @Operation(summary = "启用 APP版本", description = "启用 APP版本")
    @PostMapping(value = "/enable")
    ResponseData<Boolean> enable(@Valid @RequestBody AppVersionEnableRequest appVersionEnableRequest){
        return remoteAppVersionFeignApi.enable(appVersionEnableRequest);
    }


    /**
     * 禁用 发布
     *
     * @param appVersionDisableRequest 发布 禁用 请求
     * @return ResponseData < Void>
     */
    @Operation(summary = "禁用 APP版本", description = "禁用 APP版本")
    @PostMapping(value = "/disable")
    ResponseData<Boolean> disable(@Valid @RequestBody AppVersionDisableRequest appVersionDisableRequest){
        return remoteAppVersionFeignApi.disable(appVersionDisableRequest);
    }

    /**
     * 获取 发布
     *
     * @param appVersionGetRequest 发布 获取 请求
     * @return ResponseData < AppVersionResponse>
     */
    @Operation(summary = "获取 APP版本", description = "获取 APP版本")
    @PostMapping(value = "/get")
    ResponseData<AppVersionResponse> get(@Valid @RequestBody AppVersionGetRequest appVersionGetRequest){
        return remoteAppVersionFeignApi.get(appVersionGetRequest);
    }

    /**
     * 列表 发布
     *
     * @param appVersionListRequest 发布 列表 请求
     * @return ResponseData < AppVersionResponse>
     */
    @Operation(summary = "列表 APP版本", description = "列表 APP版本")
    @PostMapping(value = "/list")
    ResponseData<List<AppVersionResponse>> list(@Valid @RequestBody AppVersionListRequest appVersionListRequest){
        return remoteAppVersionFeignApi.list(appVersionListRequest);
    }

    /**
     * 分页 发布
     *
     * @param appVersionPageRequest 发布 分页 请求
     * @return ResponseData < AppVersionResponse>
     */
    @Operation(summary = "分页 APP版本", description = "分页 APP版本")
    @PostMapping(value = "/page")
    ResponseData<PaginationData<AppVersionResponse>> page(@Valid @RequestBody AppVersionPageRequest appVersionPageRequest){
        return remoteAppVersionFeignApi.page(appVersionPageRequest);
    }

    /**
     * 检查版本
     *
     * @param appVersionCheckVersionRequest 版本检查 请求
     * @return ResponseEntity<Response < Long>>
     */
    @Operation(summary = "检查版本 APP版本", description = "检查版本 APP版本")
    @PostMapping(value = "/check-version")
    ResponseData<CheckVersionResponse> checkVersion(@Valid @RequestBody AppVersionCheckVersionRequest appVersionCheckVersionRequest){
        return remoteAppVersionFeignApi.checkVersion(appVersionCheckVersionRequest);
    }

}